{extend name="public/base"/}
{block name="body"}
<title>客户服务</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>客户服务<span class="c-gray en">&gt;</span>服务流程<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
		<form class="form form-horizontal section" id="form-admin-add">
			<section>
					<input type="hidden" class="input-text" value="{$data.id}" id="id" name="id">
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">SEO关键词：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.seo_keywords}" id="seo_keywords" name="seo_keywords">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">SEO描述：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.seo_description}" id="seo_description" name="seo_description">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">标题：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.title}" id="title" name="title">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">副标题：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.subtitle}" id="subtitle" name="subtitle">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">图片1：</label>
						<div class="formControls col-xs-8 col-sm-9">
			                <div style="position:relative;" id="drop_area_o"></div>
			                <p style="color:#ccc;font-size:12px;">建议尺寸宽高:380*240</p>
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">图片1名称：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.img_o_title}" id="img_o_title" name="img_o_title">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">图片2：</label>
						<div class="formControls col-xs-8 col-sm-9">
			                <div style="position:relative;" id="drop_area_t"></div>
			                <p style="color:#ccc;font-size:12px;">建议尺寸宽高:380*240</p>
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">图片2名称：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.img_t_title}" id="img_t_title" name="img_t_title">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">图片3：</label>
						<div class="formControls col-xs-8 col-sm-9">
			                <div style="position:relative;" id="drop_area_th"></div>
			                <p style="color:#ccc;font-size:12px;">建议尺寸宽高:380*240</p>
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">图片3名称：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="{$data.img_th_title}" id="img_th_title" name="img_th_title">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-3 col-sm-2">流程图：</label>
						<div class="formControls col-xs-8 col-sm-9">
			                <div style="position:relative;" id="drop_area_pro"></div>
			                <p style="color:#ccc;font-size:12px;">建议尺寸宽高:1078*1057</p>
						</div>
					</div>
			</section>

			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-3 col-sm-offset-2">
					<input id="submit" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
				</div>
			</div>
		</form>
		
</article>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/public/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="/public/static/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="/public/static/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="/public/static/js/upload.js"></script>
<script type="text/javascript">
var img_o;
var img_t;
var img_th;
var img_process;
$(function(){
	$('#drop_area_o div img').attr('src','/public{$data.img_o}');
	$('#drop_area_o div img').attr('onerror',"javascript:this.src='/public/static/img/upload.png'");
	$('#drop_area_t div img').attr('src','/public{$data.img_t}');
	$('#drop_area_t div img').attr('onerror',"javascript:this.src='/public/static/img/upload.png'");
	$('#drop_area_th div img').attr('src','/public{$data.img_th}');
	$('#drop_area_th div img').attr('onerror',"javascript:this.src='/public/static/img/upload.png'");
	$('#drop_area_pro div img').attr('src','/public{$data.img_process}');
	$('#drop_area_pro div img').attr('onerror',"javascript:this.src='/public/static/img/upload.png'");
	if($("#drop_area_o div img").attr('src')=='/public/static/img/upload.png'){
		img_o='';
	}else{
		img_o= `{$data.img_o}`;
	}
	if($("#drop_area_t div img").attr('src')=='/public/static/img/upload.png'){
		img_t='';
	}else{
		img_t= `{$data.img_t}`;
	}
	if($("#drop_area_th div img").attr('src')=='/public/static/img/upload.png'){
		img_th='';
	}else{
		img_th= `{$data.img_th}`;
	}
	if($("#drop_area_pro div img").attr('src')=='/public/static/img/upload.png'){
		img_process='';
	}else{
		img_process= `{$data.img_process}`;
	}
});
var dragImgUpload = new DragImgUpload("#drop_area_o",{
    callback:function (files) {
        //回调函数，可以传递给后台等等
        if(files[0].size<3145728){
	        var file = files[0];
	        var formData = new FormData();
	        formData.append("file",file);
	        $.ajax({
	              type: 'POST',
	              url: "{:url('uploadtmd')}",
	              data:formData,
	              contentType: false, /*不可缺*/
	              processData: false, /*不可缺*/
	              success: function(response){
	                if(response.code==200){
	                  img_o=response.photo
	                }else{
	                  alert(response.msg);
	                }
	              },
	              error: function(err){

	              }
	        })
        }else{
        	alert('出错');
        	location.replace(location.href);
        }
    }
});
var dragImgUpload = new DragImgUpload("#drop_area_t",{
    callback:function (files) {
        //回调函数，可以传递给后台等等
        if(files[0].size<3145728){
	        var file = files[0];
	        var formData = new FormData();
	        formData.append("file",file);
	        $.ajax({
	              type: 'POST',
	              url: "{:url('uploadtmd')}",
	              data:formData,
	              contentType: false, /*不可缺*/
	              processData: false, /*不可缺*/
	              success: function(response){
	                if(response.code==200){
	                  img_t=response.photo
	                }else{
	                  alert(response.msg);
	                }
	              },
	              error: function(err){

	              }
	        })
        }else{
        	alert('出错');
        	location.replace(location.href);
        }
    }
});
var dragImgUpload = new DragImgUpload("#drop_area_th",{
    callback:function (files) {
        //回调函数，可以传递给后台等等
        if(files[0].size<3145728){
	        var file = files[0];
	        var formData = new FormData();
	        formData.append("file",file);
	        $.ajax({
	              type: 'POST',
	              url: "{:url('uploadtmd')}",
	              data:formData,
	              contentType: false, /*不可缺*/
	              processData: false, /*不可缺*/
	              success: function(response){
	                if(response.code==200){
	                  img_th=response.photo
	                }else{
	                  alert(response.msg);
	                }
	              },
	              error: function(err){

	              }
	        })
        }else{
        	alert('出错');
        	location.replace(location.href);
        }
    }
});
var dragImgUpload = new DragImgUpload("#drop_area_pro",{
    callback:function (files) {
        //回调函数，可以传递给后台等等
        if(files[0].size<3145728){
	        var file = files[0];
	        var formData = new FormData();
	        formData.append("file",file);
	        $.ajax({
	              type: 'POST',
	              url: "{:url('uploadtmd')}",
	              data:formData,
	              contentType: false, /*不可缺*/
	              processData: false, /*不可缺*/
	              success: function(response){
	                if(response.code==200){
	                  img_process=response.photo
	                }else{
	                  alert(response.msg);
	                }
	              },
	              error: function(err){

	              }
	        })
        }else{
        	alert('出错');
        	location.replace(location.href);
        }
    }
});
$("#submit").click(function() {
	layer.load(1, {
	  shade: [0.1,'#fff'] //0.1透明度的白色背景
	});
	var title=$("input[name=title]").val();
	var subtitle=$("input[name=subtitle]").val();
	var img_o_title=$("input[name=img_o_title]").val();
	var img_t_title=$("input[name=img_t_title]").val();
	var img_th_title=$("input[name=img_th_title]").val();
	var seo_keywords=$("input[name=seo_keywords]").val();
	var seo_description=$("input[name=seo_description]").val();
	$.ajax({
	    type: 'POST',
	    url: "{:url('server_process')}",
	    data: {title:title,img_o_title:img_o_title,img_t_title:img_t_title,img_th_title:img_th_title,img_o:img_o,img_t:img_t,img_th:img_th,img_process:img_process,subtitle:subtitle,seo_description:seo_description,seo_keywords:seo_keywords},
	    success: function(resdata){
	        if(resdata.code==200){
				layer.msg(resdata.msg,{icon:1,time:1000});
				setTimeout("location.reload()",1000);
	        }else{
				layer.msg(resdata.msg,{icon:2,time:3000});
	        }
	    },
	    error: function(){
			layer.msg('数据保存失败',{icon:2,time:3000});
	    }
	})
	
    
})
</script> 

{/block}